rm(list = ls())


# Set Working Directory to Replication Folder
taskdir 		<- "~/Dropbox/final_hai_perlman_replication/"
inputdir 		<- paste0(taskdir, "input/processing/regressions_survey1/")

setwd(taskdir)
library(tidyverse)
library(lfe)
require(data.table)
library(stringi)
library(stargazer)
library(kableExtra)
library(modelsummary)



# Load regression results
load(paste0(inputdir, 'ols_survey1_subset_wildfireexposure.RData'))


# We need this only for the main DVs
main_dvs <- c('politician_understand' ,
			  'politician_prevent' ,
			   'politician_advocate' ,
			   'politician_sympathy',
			   'tax_support')
main_dvs_labels <- c('has a good understanding of wildfires and their causes?' ,
			  'will work to prevent future wildfires?' ,
			   'will be an effective advocate for federal disaster relief?' ,
			   'How sympathetic did the politician seem?',
			   'How likely would you be to support this new tax?')



for (i in 1:length(main_dvs)) {
dv <- main_dvs[i]
stargazer(outlist[[dv]], 
		  se = outlist[[dv]]%>%unname()%>%lapply(FUN = function(m)m$rse),
		  column.labels = c('Pooled', 'Republicans', 
		  					  'Democrats', 'Independents'),
		  column.sep.width = "2pt",
		  dep.var.labels = main_dvs_labels[i], 
		  float = FALSE,
		  notes = 'Regressions also include fixed effects for income level.',
		  out = paste0(taskdir, 'output/regression_tables/ols_survey1_subset_wildfireexposure/mainresults_subset_wildfireexposure_table_',i))
}
